/**
 为Array对象添加一个去除重复项的方法
 input:
 [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a', 'a', NaN]

 output:
 [false, true, undefined, null, NaN, 0, 1, {}, {}, 'a']

 这里要注意，NaN == NaN 为false，[] == []为false, {} == {} 为false, 1与'1'不相同
 */


let uniq = function (arr) {
    var res = [];
    var flag = true;
    arr.forEach(function(x) {
        if (res.indexOf(x) == -1) {
            if (x !== x) {
                if (flag) {
                    res.push(x);
                    flag = false;
                }
            } else {
                res.push(x);
            }
        }
    })
    return res;
}



let arr = [false, true, undefined, null, NaN, NaN, 0, 1, '1', [], [], {}, {}, 'a', 'a','1','1']
console.log(uniq(arr));










